package com.lunhui.service.lunhui.service.business.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lunhui.monster.client.MonsterClient;
import com.lunhui.monster.client.dto.MonsterDto;
import com.lunhui.service.lunhui.service.business.MonsterService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author renminghe-kg
 */
@Service("monsterService")
public class MonsterServiceImpl implements MonsterService {
    private static final Logger logger = LoggerFactory.getLogger(MonsterServiceImpl.class);

    @Reference
    private MonsterClient monsterClient;

    private int pageNo = 0;
    private int pageSize = 25;

    @Override
    public PageInfo<MonsterDto> getMonsterListInfo(int areaId, int sceneId) throws RuntimeException {

        try {
            PageHelper.startPage( pageNo , pageSize );

            List<MonsterDto> monsterListInfo = monsterClient.getMonsterListInfo(areaId, sceneId);

            return new PageInfo<>(monsterListInfo);

        } catch (Exception e) {
            logger.error("获取怪物服务数据失败: " + e);
            throw new RuntimeException(e);
        }
    }
}